<% content_for :css do %>
  <%= stylesheet_link_tag 'site_healths_stat'  %>
<% end %>
<div class='total_stat' >
  <table cellspan='1' cellpadding='1' border='0'>
    <tr>
      <th colspan='7'><%= @setting.name %>-健康状况-综合分析</th>
    </tr>
    <tr>
      <th rowspan='2' width='100'></th>
      <th rowspan='2' width='200'>健康度</th>
      <th rowspan='2'width='200'>可用</th>
      <th rowspan='2'width='200'>失效</th>
      <th colspan='3'>响应时间</th>      
    </tr>
    <tr>
      <th width='200'>平均</th>
      <th width='200'>最快</th>
      <th width='200'>最慢</th>
    </tr>
    <tr>
      <th>本年度</th>
      <% if @setting.this_year_stat %>
      <td><%= @setting.this_year_stat.stat_health_degree %>%</td>
      <td><%= @setting.this_year_stat.stat_available_site_heart_beats_count %>次</td>
      <td><%= @setting.this_year_stat.stat_unavailable_site_heart_beats_count %>次</td>
      <td><%= @setting.this_year_stat.stat_avg_response_time %>ms</td>
      <td><%= @setting.this_year_stat.the_fastest_heart_beat.response_time %>ms</td>
      <td><%= @setting.this_year_stat.the_slowest_heart_beat.response_time %>ms</td>
      <% else %>
      <td>--</td>
      <td>--</td>
      <td>--</td>
      <td>--</td>
      <td>--</td>
      <td>--</td>
      <% end %>
    </tr>
    <tr>
      <th>本季度</th>
      <% if @setting.this_quarter_stat %>
      <td><%= @setting.this_quarter_stat.stat_health_degree %>%</td>
      <td><%= @setting.this_quarter_stat.stat_available_site_heart_beats_count %>次</td>
      <td><%= @setting.this_quarter_stat.stat_unavailable_site_heart_beats_count %>次</td>
      <td><%= @setting.this_quarter_stat.stat_avg_response_time %>ms</td>
      <td><%= @setting.this_quarter_stat.the_fastest_heart_beat.response_time %>ms</td>
      <td><%= @setting.this_quarter_stat.the_slowest_heart_beat.response_time %>ms</td>
      <% else %>
      <td>--</td>
      <td>--</td>
      <td>--</td>
      <td>--</td>
      <td>--</td>
      <td>--</td>
      <% end %>
    </tr>
    <tr>
      <th>本月份</th>
      <% if @setting.this_month_stat %>
      <td><%= @setting.this_month_stat.stat_health_degree %>%</td>
      <td><%= @setting.this_month_stat.stat_available_site_heart_beats_count %>次</td>
      <td><%= @setting.this_month_stat.stat_unavailable_site_heart_beats_count %>次</td>
      <td><%= @setting.this_month_stat.stat_avg_response_time %>ms</td>
      <td><%= @setting.this_month_stat.the_fastest_heart_beat.response_time %>ms</td>
      <td><%= @setting.this_month_stat.the_slowest_heart_beat.response_time %>ms</td>
      <% else %>
      <td>--</td>
      <td>--</td>
      <td>--</td>
      <td>--</td>
      <td>--</td>
      <td>--</td>
      <% end %>
    </tr>
    <tr>
      <th>本周</th>
      <% if @setting.this_week_stat %>
      <td><%= @setting.this_week_stat.stat_health_degree %>%</td>
      <td><%= @setting.this_week_stat.stat_available_site_heart_beats_count %>次</td>
      <td><%= @setting.this_week_stat.stat_unavailable_site_heart_beats_count %>次</td>
      <td><%= @setting.this_week_stat.stat_avg_response_time %>ms</td>
      <td><%= @setting.this_week_stat.the_fastest_heart_beat.response_time %>ms</td>
      <td><%= @setting.this_week_stat.the_slowest_heart_beat.response_time %>ms</td>
      <% else %>
      <td>--</td>
      <td>--</td>
      <td>--</td>
      <td>--</td>
      <td>--</td>
      <td>--</td>
      <% end %>
    </tr>
    <tr>
      <th>今日</th>
      <% if @setting.todays_stat %>
      <td><%= @setting.todays_stat.health_degree %>%</td>
      <td><%= @setting.todays_stat.available_site_heart_beats_count %>次</td>      
      <td><%= @setting.todays_stat.unavailable_site_heart_beats_count %>次</td>
        <% if @setting.todays_stat.the_fastest_heart_beat %>
        <td><%= @setting.todays_stat.avg_response_time %>ms</td>
        <td><%= @setting.todays_stat.the_fastest_heart_beat.response_time %>ms</td>
        <td><%= @setting.todays_stat.the_slowest_heart_beat.response_time %>ms</td>
        <% else %>
        <td>--</td>
        <td>--</td>
        <td>--</td>
        <% end %>
      <% else %>
      <td>--</td>
      <td>--</td>
      <td>--</td>
      <td>--</td>
      <td>--</td>
      <td>--</td>
      <% end %>
    </tr>
  </table>
</div>
<div id='heart_beats' class='heart_beats'>
  <%= render :file => 'tools/site_healths/stat.js' %>
</div>